package util
{
	import kinds.MethodOptionKind;
	
	import tag.doABC2.CPool;

	public class CPoolUtils
	{
		public static function optionValue(cp:CPool, kind:uint, index:int):String
		{
			var ret:String = "";
			if(cp != null){
				switch(kind){
					case MethodOptionKind.CONSTANT_Int:
						ret = "" + cp.cp_int[index];
						break;
					case MethodOptionKind.CONSTANT_Uint:
						ret = "" + cp.cp_uint[index];
						break;
					case MethodOptionKind.CONSTANT_Double:
						ret = "" + cp.cp_double[index];
						break;
					case MethodOptionKind.CONSTANT_Utf8:
						ret = "\"" + cp.cp_string[index] + "\"";
						break;
					case MethodOptionKind.CONSTANT_True:
						ret = 'true';
						break;
					case MethodOptionKind.CONSTANT_False:
						ret = 'false';
						break;
					case MethodOptionKind.CONSTANT_Null:
						ret = 'null';
						break;
					case MethodOptionKind.CONSTANT_Undefined:
						ret = 'undefined';
						break;
					case MethodOptionKind.CONSTANT_Namespace:
					case MethodOptionKind.CONSTANT_PackageNamespace:
					case MethodOptionKind.CONSTANT_PackageInternalNs:
					case MethodOptionKind.CONSTANT_ProtectedNamespace:
					case MethodOptionKind.CONSTANT_ExplicitNamespace:
					case MethodOptionKind.CONSTANT_StaticProtectedNs:
					case MethodOptionKind.CONSTANT_PrivateNs:
						ret = '' + cp.cp_namespace[index];
						break;
				}
			}
			return ret;
		}
	}
}